// 引入
import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'


// 定义一些路由
// 每个路由都需要映射到一个组件。
export const allRoutes: RouteRecordRaw[] = [
  {
    path: '/',
    name: 'layout',
    redirect: '/home',
    meta: {
      title: '',
      hidden: false,
      level: 1,
    },
    component: () => import('@/views/Layout/index.vue'),
    children: [
      {
        path: '/home',
        name: 'home',
        meta: {
          title: '首页',
          hidden: false,
          icon: 'HomeFilled'
        },
        component: () => import('@/views/Home/index.vue')
      },
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/Login/index.vue')
  },
  {
    path: '/404',
    name: '404',
    component: () => import('@/views/NotFound/index.vue')
  },
  {
    path: '/screen',
    name: 'screen',
    meta: {
      title: '数据大屏',
      hidden: false,
      icon: 'DataBoard'
    },
    component: () => import('@/views/screen/index.vue')
  },
  {
    path: '/acl',
    name: 'acl',
    meta: {
      title: '权限管理',
      hidden: false,
      icon: 'Lock'
    },
    redirect: '/acl/user',
    component: () => import('@/views/Layout/index.vue'),
    children: [
      {
        path: '/acl/user',
        name: 'user',
        meta: {
          title: '用户管理',
          hidden: false,
          icon: 'User'
        },
        component: () => import('@/views/acl/user/index.vue'),
      },
      {
        path: '/acl/role',
        name: 'role',
        meta: {
          title: '角色管理',
          hidden: false,
          icon: 'Collection'
        },
        component: () => import('@/views/acl/role/index.vue'),
      },
      {
        path: '/acl/permission',
        name: 'permission',
        meta: {
          title: '菜单管理',
          hidden: false,
          icon: 'Fries'
        },
        component: () => import('@/views/acl/permission/index.vue'),
      },
    ]
  },
  {
    path: '/product',
    name: 'product',
    meta: {
      title: '商品管理',
      hidden: false,
      icon: 'ShoppingBag'
    },
    redirect: '/product/trademark',
    component: () => import('@/views/Layout/index.vue'),
    children: [
      {
        path: '/product/trademark',
        name: 'trademark',
        meta: {
          title: '品牌管理',
          hidden: false,
          icon: 'ShoppingCartFull'
        },
        component: () => import('@/views/product/trademark/index.vue')
      },
      {
        path: '/product/attr',
        name: 'attr',
        meta: {
          title: '属性管理',
          hidden: false,
          icon: 'ChromeFilled'
        },
        component: () => import('@/views/product/attr/index.vue'),
      },
      {
        path: '/product/spu',
        name: 'spu',
        meta: {
          title: 'SPU管理',
          hidden: false,
          icon: 'Calendar'
        },
        component: () => import('@/views/product/spu/index.vue'),
      },
      {
        path: '/product/sku',
        name: 'sku',
        meta: {
          title: 'SKU管理',
          hidden: false,
          icon: 'Orange'
        },
        component: () => import('@/views/product/sku/index.vue'),
      },
    ]
  },
  {
    path: '/:pathMatch(.*)*',
    redirect: '/404'
  },
]

// 创建路由实例并传递 `routes` 配置
const router = createRouter({
  // 内部提供了 history 模式的实现
  history: createWebHistory(),
  routes: allRoutes
})

// 导出
export default router